package com.hebeu.gfh.service.impl;

import com.hebeu.gfh.mapper.ActivitiesMapper;
import com.hebeu.gfh.pojo.po.Activities;
import com.hebeu.gfh.pojo.vo.pages;
import com.hebeu.gfh.service.activitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 刘剑利
 * @Version: v1.0
 */
@Service("ActivitiesService")
public class activitiesServiceImpl implements activitiesService {
    @Autowired
    ActivitiesMapper activitiesMapper;

    private int total;

    @Override
    public List<Activities> findAllActivities(pages page) {
        int a =page.getPage();
        page.setPage((a - 1) * page.getPagesize());
        List<Activities> activitiesList = activitiesMapper.findAllActivities(page);
        return activitiesList;
    }

    @Override
    public List<Activities> findActivitiesByclubId(int clubId) {
        List<Activities> activitiesList = activitiesMapper.findActivitiesByclubId(clubId);
        return activitiesList;
    }

    @Override
    public Activities findActivitiesByactivityId(int activityId) {
        Activities activitiesList = activitiesMapper.findActivitiesByactivityId(activityId);
        return activitiesList;
    }

    @Override
    public List<Activities> findActivityByuserId(int userId) {
        List<Activities> activitiesList = activitiesMapper.findActivityByuserId(userId);
        return activitiesList;
    }

    @Override
    public int findActivityNum() {
        int num =activitiesMapper.findActivityNum();
        return num;
    }

    @Override
    public void initActivity(Activities activities) {
        activities.setParticipants(0);
        activitiesMapper.initActivity(activities);
    }

    @Override
    public int isparticipate(int activityId, int userId) {
        int isparticipate = activitiesMapper.isparticipate(activityId,userId);
        return isparticipate;
    }

    @Override
    public void addActivityRegistration(int acitivityId, int userId) {
        activitiesMapper.addActivityRegistration(acitivityId,userId);
    }

    public void deleteActivityRegistration(int acitivityId, int userId) {
        activitiesMapper.deleteActivityRegistration(acitivityId,userId);
    }

    @Override
    public int findParticipant(int activityId) {
        int num =activitiesMapper.findParticipant(activityId);
        return num;
    }

    @Override
    public List<Activities> findActivityByuserId1(pages pages) {
        int a =pages.getPage();
        pages.setPage((a - 1) * pages.getPagesize());
        List<Activities> activitiesList = activitiesMapper.findActivityByuserId1(pages);
        return activitiesList;
    }

    @Override
    public int getActivityNum(int userId) {
        int total = activitiesMapper.getActivityNum(userId);
        return total;
    }

    @Override
    public List<Activities> getActivityInfoByName(pages pages) {
        int a =pages.getPage();
        pages.setPage((a - 1) * pages.getPagesize());
        List<Activities> activitiesList = activitiesMapper.getActivityInfoByName(pages);
        total = activitiesList.size();
        return activitiesList;
    }

    @Override
    public int getActivityNum1(int userId) {
        int total1 = total;
        return total1;
    }

    @Override
    public void deleteActivityById(int activityId) {
        activitiesMapper.deleteActivityById(activityId);
    }
}
